#include "GlSprite.h"

#include "GlPosition.h"
#include "GlSize.h"
#include "Utility.h"

namespace GraphicLibrary
{
	//-------------------------------------------
	Sprite::Factory::~Factory()
	{
	}
}

namespace GraphicLibrary
{
	Sprite::Factory *Sprite::msFactory(0);
	//-------------------------------------------
	Size Sprite::getExactSize() const
	{
		Size size = getSize();
		Size scale = getScale();
		return Size(size.mWidth * scale.mWidth , size.mHeight * scale.mHeight);
	}

	//-------------------------------------------
	void Sprite::stretch(const Position &begin, const Position &end)
	{
		Position center = (begin + end) * 0.5f;
		move(center);
		setDirection(getAngleTo(end));
		Size newSize;
		newSize.mWidth = (end - begin).length();
		newSize.mHeight = getSize().mHeight;
		setSize(newSize);
	}

	//-------------------------------------------
	Sprite* Sprite::Create(const char *spriteName)
	{
		return msFactory->create(spriteName);
	}
}
